import { observable, action, makeObservable } from "mobx";
import { PageDateSelect } from '@/types/pages/enum'
import { ILogisticsFull } from "@/types/pages/logistics/interface";
import {getTotalTransportData,getTransportList,getLogisticsQuantity,getPieLeftChart,getPieRightChart,getMapChinaChart } from "@/api/logistics";
import { IStore } from "@/types/pages/base";


/**
 * class Logistics
 * 物流分析
 */
class Logistics implements IStore<ILogisticsFull>  {
    @observable screenData: ILogisticsFull= {totalTransport:{},tarnTransport:{},carTransport:{},
      pieLeftChart:{},pieRightChart:{},transportList:{},logisticsQuantity:[],chinaChart:{}}

    constructor() {
      makeObservable(this)
  }
   /**
     *
     * @param type 日期选择函数
     * @param date 传入日期
     */
     @action async getScreenData(type: PageDateSelect,date?:Date) {

        // 获取左上部分
        const {totalTransport,tarnTransport,carTransport}=await getTotalTransportData(type,date);
        this.screenData.totalTransport= totalTransport
        this.screenData.tarnTransport= tarnTransport;
        this.screenData.carTransport= carTransport;
        this.screenData.pieLeftChart= await getPieLeftChart(type,date);
        this.screenData.pieRightChart= await getPieRightChart(type,date);
        this.screenData.transportList= await getTransportList(type,date);
        this.screenData.logisticsQuantity=await  getLogisticsQuantity(type,date);
        this.screenData.chinaChart=await  getMapChinaChart(type,date);

        return  this.screenData;
    }




}
export default Logistics;
